package com.ykw.parking.mapper;

import com.ykw.parking.pojo1.*;
import org.apache.ibatis.annotations.*;

import javax.mail.MailSessionDefinition;
import java.util.List;

@Mapper
public interface OrderMapper {

    @Select("select * from parking_lot where id=#{id}")
    public ParkingLot getParkingLot(@Param("id") Integer id);

    @Select("select * from parking_one where id=#{id}")
    public Parking getParking(@Param("id") Integer id);


    public int addOrder( UserOrder userOrder);

    @Delete("delete from shoppingcart where parkingid=#{parkingid} and userid=#{userid}")
    public int deleteSC(@Param("parkingid") String parkingid,@Param("userid") String userid);

    @Update("Update parking_lot set sale=#{sale} where id=#{id}")
    public int updateParkingLot(@Param("sale") Integer sale, @Param("id") Integer id);

    @Select("select * from user_order where uid=#{uid} and plid=#{plid}")
    public UserOrder queryOrder(@Param("uid")String uid,@Param("plid")Integer plid);


    @Update("Update user_order set state=-1 where plid=#{plid} and oid!=#{oid}")
    public int updateOrder(@Param("oid") String oid, @Param("plid") Integer plid);

    @Update("Update user_order set state=1 where plid=#{plid} and oid=#{oid}")
    public int updateOrderAndOne(@Param("oid") String oid, @Param("plid") Integer plid);

    public int addUserPaking(UserParking userParking);
    @Select("select * from real_user where id=#{id}")
    public RealUser queryUser(@Param("id") String id);

    @Select("select * from user_order where uid=#{uid} order by `date` DESC")
    public List<UserOrder>  getOrder(String uid);
    @Delete("delete from user_order where oid=#{oid}")
    public int delOrder(@Param("oid") String oid);

    @Select("select * from user_order where oid=#{oid} ")
    public UserOrder getOrderByOid(String oid);

    @Select("select price from user_order where oid=#{oid} ")
    public Double getOrderPrice(String oid);
    @Select("select parkingLot_id from renchou where user_id=#{user_id}")
    public List<String> getRCByPlid(@Param("user_id") String user_id);

    @Select("select count(*) userid from renchou where parkingLot_id=#{parkingLot_id}")
    public int getRCByUid( @Param("parkingLot_id") String parkingLot_id);

    @Delete("delete from renchou where user_id=#{user_id} and parkingLot_id=#{parkingLot_id}")
    public int delRC(@Param("user_id") String user_id,@Param("parkingLot_id") String parkingLot_id);

/*    @Update("Update parking_lot set identify=1 where id=#{id}")
    public int updateParkingLotByRc(@Param("id") Integer id);*/
}
